<template>
	<view>
		<view class="border-bottom border-top bg-white mt-3">
			<view class="border-bottom ml-4 py-2">
				<input type="text" placeholder="请输入旧密码" v-model="oldpass" placeholder-class="font" @input="old_input" />
			</view>
			<view class="border-bottom ml-4 py-2">
				<input type="text" placeholder="请输入新密码" v-model="newpass" placeholder-class="font" @input="new_input" />
			</view>
			
			<view class="ml-4 py-2 d-flex j-sb">
				<input type="text" placeholder="请确认新密码" v-model="compass" placeholder-class="font" @input="com_input" />
			</view>
		</view>
		<view class="font py-3 ml-4">确认密码和新密码需要保持一致</view>
		<view class="mx-3 mt-1">
			<button type="warn" @click="sub">确定</button>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldpass:"",// 旧密码
				newpass:"",// 新密码
				compass:'',// 确认
			}
		},
		onLoad() {
			
		},
		methods: {
			showToast_fill() {
				this.$refs.uToast.show({
					title: '确认密码和新密码需要保持一致',
					type: 'default',
				})
			},
			// 旧密码
			old_input(e){
				this.oldpass=e.detail.value
			},
			// 新密码
			new_input(e){
				this.newpass=e.detail.value
			},
			// 确认密码
			com_input(e){
				this.compass=e.detail.value
			},
			// 提交
			sub(){
				if(this.newpass==this.compass){
					this.$H.post("admin/user/update",{
						old_password:this.oldpass,
						new_password:this.newpass
					}).then(res=>{
						console.log(res)
						uni.navigateBack({
							delta:1
						})
					})
				}else{
					this.showToast_fill()
				}
				
			}
		}
	}
</script>

<style>

</style>
